<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('钱宝官品交易信息列表')" />
    <style>
        #content {
            position:absolute;
            top:0;
            bottom:0;
            left:0;
            right:0;
            margin:auto;
            height:440px;
            width:70%;
            background: #346FCE;
        }
    </style>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label style="width: 120px">品牌名称：</label>
                            <select name="manuNum" >
                                <option value="">选择品牌</option>
                                <option th:each="m:${manufacturer}" th:text="${m.MANU_NAME}" th:value="${m.MANU_NUM}"></option>
                            </select>
                        </li>
                        <li>
                            <label style="width: 120px;">渠道参考号：</label>
                            <input type="text" name="rrno"/>
                        </li>
                        <li>
                            <label style="width: 120px;">渠道商户号：</label>
                            <input type="text" name="merno"/>
                        </li>
                        <li>
                            <label style="width: 120px;">SN：</label>
                            <input type="text" name="sn"/>
                        </li>
                        <li>
                            <label style="width: 120px;">渠道服务商编号：</label>
                            <input type="text" name="agentno"/>
                        </li>
                        <li>
                            <label style="width: 120px;">处理状态：</label>
                            <select name="status">
                                <option value="">所有</option>
                                <option value="0">正在处理</option>
                                <option value="1">处理完成</option>
                            </select>
                        </li>
                        <li>
                            <label style="width: 120px;">交易时间：</label>
                            <input type="text" class="time-input" readonly name="start" placeholder="开始时间"/>
                        </li>
                        <li>-</li>
                        <li>
                            <input type="text" class="time-input" readonly name="end" placeholder="结束时间"/>
                        </li>
                        <li>
                            <label style="width: 10px;"></label>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 search-collapse">
            <span style="color:blue">[</span>
            <span style="color: blue;font-style: initial">交易总笔数：</span>
            <span id="counten" style="color: red;font-style: initial">0</span><span style="color: blue;font-style: initial"> 笔</span>
            <span style="color:blue">]</span>
            <span style="color:blue">[</span>
            <span style="color: blue;font-style: initial">交易商户数：</span>
            <span id="mercount" style="color: red;font-style: initial">0</span><span style="color: blue;font-style: initial"> 个</span>
            <span style="color:blue">]</span>
            <span style="color:blue">[</span>
            <span style="color: blue;font-style: initial">交易总金额：</span>
            <span id="amount" style="color: red;font-style: initial">0.00</span><span style="color: blue;font-style: initial"> 元</span>
            <span style="color:blue">]</span>
        </div>
        <div class="btn-group-sm" id="toolbar" role="group">
            <!-- <a class="btn btn-primary single" onclick="audit()" shiro:hasPermission="bankExpenditure:gbTradeInfo:sync">
                 <i class="fa fa-edit"></i> 推送交易分润
             </a>-->
            <a class="btn btn-success" onclick="$.table.importExcel()" >
                <i class="fa fa-upload"></i> 交易对账
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" class="table text-nowrap"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('bankExpenditure:gbTradeInfo:edit')}]];
    var removeFlag = [[${@permission.hasPermi('bankExpenditure:gbTradeInfo:remove')}]];
    var terminalTypeDatas = [[${@dict.getType('terminal_type')}]];

    var prefix = ctx + "bankExpenditure/gbTradeInfoTemp";

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            importUrl: prefix + "/importTemplate",
            modalName: "交易信息",
            firstLoad:false,
            responseHandler:responseHandler,
            clickToSelect:true,
            columns: [{
                radio: true
            },
                {
                    field: 'rrno',
                    title: '渠道参考号',
                },
                {
                    field: 'merno',
                    title: '渠道商户编号'
                },
                {
                    field: 'manuName',
                    title: '品牌名称'
                },
                {
                    field: 'sn',
                    title: '终端号'
                },
                {
                    field: 'agentno',
                    title: '渠道服务商编号'
                },
                {
                    field: 'localdate',
                    title: '交易时间',
                    formatter: function (value, row, index) {
                        var time = $.common.isEmpty(row.localtime) ? "" : row.localtime;
                        return value + " " + time;
                    }
                },
                {
                    field: 'pan',
                    title: '交易卡号'
                },
                {
                    field: 'amount',
                    title: '交易金额(元)'
                },

                {
                    field: 'status',
                    title: '处理状态',
                    formatter: function (value, row, index) {
                        if ("0" == value) {
                            return '<span style="color:red;">正在处理</span>';
                        } else if ("1" == value) {
                            return '<span style="color:green;">处理完成</span>';
                        } else {
                            return "暂无";
                        }
                    }
                },
]
        };
        $.table.init(options);
    });

    function responseHandler(res) {
        $("#counten").text(res.data.PAY_COUNT);
        $("#amount").text(res.data.AMOUNT);
        $("#mercount").text(res.data.MER_COUNT);
    }

    function audit() {
        var merno = $.table.selectColumns("merno")[0];
        var msgtype = $.table.selectColumns("msgtype")[0];
        var serial = $.table.selectColumns("serial")[0];
        var rrno = $.table.selectColumns("rrno")[0];
        $.modal.confirm("确认要推送吗", function () {
            var url = prefix + "/sync";
            var data = {"merno": merno,"msgtype": msgtype,"serial": serial,"rrno": rrno};
            $.operate.post(url, data);
        });
    }
</script>

<!-- 导入区域 -->
<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
            <div class="form-group">
                <label class="col-sm-3 control-label">交易渠道：</label>
                <div class="col-sm-8">
                    <select required name="tradeType" class="form-control m-b is-required">
                        <option value="">请选择</option>
                        <option value="4">中付</option>
                        <option value="5">合大宝</option>
                        <option value="1">乐刷</option>
                        <option value="3">钱创付</option>
                        <option value="2">钱宝GB</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">上传文件：</label>
                <div class="col-sm-8">
                    <input type="file" id="file" name="file"/>
                </div>
            </div>
            <!--<div class="mt10 pt5">
                &nbsp;	<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
            </div>-->
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
    </form>
</script>

</body>
</html>
